<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      function Father(uname, age, gender) {
        // console.log(this)
        this.uname = uname

        this.age = age

        this.gender = gender
      }

      Father.prototype.money = function () {
        console.log('赚了一个小目标')
      }

      const father = new Father('董', 56, '男')

      //   father.money()

      //   console.log(father)

      //属性继承
      function Son(uname, age, gender, face) {
        // console.log(this)
        Father.call(this, uname, age, gender)

        this.face = face
      }
      //直接继承了原型对象，但是会造成耦合的问题
      //   Son.prototype = Father.prototype

      //继承实例化对象
      //原型链继承
      Son.prototype = new Father()

      //手动指回构造函数
      Son.prototype.constructor = Son

      Son.prototype.smoke = function () {
        console.log('我会抽烟')
      }

      const son = new Son('董', 29, '男', '帅')

      //   console.log(son)
      console.log(Son.prototype)
      son.money()

      son.smoke()

      father.smoke()

      //   function Son(uname, age, gender) {
      //     this.uname = uname

      //     this.age = age

      //     this.gender = gender
      //   }

      //   const son = new Son('董', 30, '男')
    </script>
  </body>
</html>
